<?php
	$query = "select * from `radio_dj` where `userid`='$id'";
	$result = mysql_query($query);
	if (mysql_num_rows($result)) {
		$djprofile = mysql_fetch_array($result);
		$dj_id = $djprofile['id'];
		if ($_REQUEST['delete']){
			$show_id = escapestr($_REQUEST['delete']);
			$query 	= "delete from `radio_show` where `id`='$show_id' and `dj`='$dj_id'";
			$result = mysql_query($query);
			if ($result) {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_showdeleted"),GetLangString($lang,"msg_showdeleted"));  
			} else {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_error"),GetLangString($lang,"msg_dberror").$query);  
			}
		}
		if ($_REQUEST['addshow']){
			$day 	= escapestr($_REQUEST['day']);
			$start =  escapestr($_REQUEST['start']);
			$stop =  escapestr($_REQUEST['stop']);
			
			$query 	= "insert into `radio_show` (`dj`,`day`,`start`,`stop`) values ('$dj_id','$day','$start','$stop')";
			$result = mysql_query($query);
			if ($result) {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_showadded"),GetLangString($lang,"msg_showadded"));  
			} else {
				$SITE_MIDDLE .= FormatElement (GetLangString($lang,"txt_error"),GetLangString($lang,"msg_dberror").$query);  
			}
		}
		$query 	= "select * from `radio_show` where `dj`='$dj_id' order by `day` asc";
		$result = mysql_query($query);
		$txt = "<center><table border=\"1\" width=\"90%\"><tr>
			<td width=\"25%\">".GetLangString($lang,"txt_day")."</td><td width=\"25%\">".GetLangString($lang,"txt_start")."</td><td width=\"25%\">".GetLangString($lang,"txt_stop")."</td><td width=\"25%\"></td></tr>";
		while ($show = mysql_fetch_array($result)) {
			$day = GetLangString($lang,"txt_day".$show['day']);
			$start 	= $show['start']; 
			$stop 	= $show['stop'];
			$showid = $show['id'];
			$delete = "<a href=\"/index.php?do=djshows&delete=$showid\">".GetLangString($lang,"txt_delete")."</a>"; 
			$txt .= "<tr><td>$day</td><td>$start</td><td>$stop</td><td>$delete</td></tr>";
		}
		$txt .= "</table></center>";
		$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_yourweeklyshows"),$txt); 
		$addform = "<form action=\"/index.php?do=djshows\" method=\"post\">";
		$days = "<select name=\"day\" size=\"1\"> "; 
		for ($d=1; $d < 8; $d++) {
			$days .= "<option value=\"$d\">";
			$days .= GetLangString($lang,"txt_day$d");
			$days .= "</option>";
		}
		$days .= "</select>";
		$addform .= FormatSmallElement(GetLangString($lang,"txt_day"),$days);
		$addform .= FormatSmallElement(GetLangString($lang,"txt_start"),"<input name=\"start\" type=\"text\">");
		$addform .= FormatSmallElement(GetLangString($lang,"txt_stop"), "<input name=\"stop\" type=\"text\">");
		$addform .= "<input name=\"addshow\" value=\"".GetLangString($lang,"txt_save")."\"type=\"submit\">";

		$SITE_MIDDLE .= FormatElement (GetLangString( $lang, "txt_addshow") ,$addform ) ; 

		


	}else {
		$SITE_MIDDLE .= FormatElement(GetLangString($lang,"txt_error"),GetLangString($lang,"msg_nodjerror"));
	} 

?>
